Conversation
I'm doing this because, and I'm not sure why, it's not being output to the generated SDK unless I add this, even though it's part of the template.
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThis PR adds comprehensive Ruby SDK generation support by introducing Makefile targets for Ruby client building/testing, OpenAPI generator configuration files, and 60+ Mustache templates covering API clients, models, configuration, documentation, and testing scaffolds for automated Ruby SDK generation. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can validate your CodeRabbit configuration file in your editor.If your editor has YAML language server, you can enable auto-completion and validation by adding |
There was a problem hiding this comment.
Actionable comments posted: 12
🤖 Fix all issues with AI agents
In `@config/clients/ruby/.openapi-generator-ignore`:
- Around line 1-18: The .openapi-generator-ignore file contains trailing spaces
on entries ".rspec ", ".travis.yml " and "Rakefile " causing patterns not to
match; edit the file to remove trailing whitespace from those entries so they
read ".rspec", ".travis.yml" and "Rakefile" (and scan the rest of the file for
any other trailing spaces) to ensure ignore rules behave like the intended
.gitignore-style patterns.
In `@config/clients/ruby/config.overrides.json`:
- Around line 4-5: The Ruby client override sets "packageVersion": "0.0.1" which
is inconsistent with other SDKs; confirm whether Ruby is intentionally starting
at 0.0.1 for a new SDK or update the override to match the project's standard
SDK versioning (e.g., align with 0.9.x used by other clients). If intentional,
add a clarifying comment in the override explaining why Ruby differs; otherwise
change the "packageVersion" for the packageName "openfga" to the agreed common
version (e.g., 0.9.9) so it matches the other SDKs.
- Around line 1-37: Add the missing fossaComplianceNoticeId property to the JSON
config by inserting a new top-level key "fossaComplianceNoticeId" with a unique
UUID string value (e.g., generate a new UUID v4) alongside the existing keys
like "sdkId", "gemName", and "moduleName"; ensure the key is placed at the same
object level as the other metadata fields and that the value is a quoted string
so the JSON remains valid.
In `@config/clients/ruby/template/api_client_httpx_partial.mustache`:
- Around line 54-59: The debug log references an undefined variable req_body
after assigning the request payload to body_params; update the logging to use
body_params (or assign build_request_body to req_body instead) so the debug
branch in the block handling %w[POST PATCH PUT DELETE] uses the same variable
that was created (refer to build_request_body, body_params and the
config.debugging logger call in the api_client_httpx_partial.mustache template).
In `@config/clients/ruby/template/api_client_typhoeus_partial.mustache`:
- Around line 130-159: The tempfile created in download_file (inside
request.on_headers) can be left on disk if the request later fails and call_api
raises ApiError; modify download_file so any error path deletes/unlinks the
tempfile: ensure request.on_complete inspects the final response status and,
before raising ApiError, calls tempfile.close and tempfile.unlink (or
tempfile.delete) when tempfile exists, and guard request.on_body to no-op if
tempfile is nil; also consider wrapping the lifecycle in a begin/rescue/ensure
within download_file so tempfile is always cleaned up on exceptions raised by
call_api or the request handlers.
- Line 56: The follow_location option is incorrectly always true because the
code uses truthy-or (opts[:follow_location] || true) which forces false to true;
change the assignment for follow_location to use a proper default lookup such as
using opts.fetch(:follow_location, true) or checking for nil (opts.key?/nil?
pattern) so an explicit false in opts[:follow_location] is preserved; update the
assignment where follow_location is defined to use that pattern (referencing the
follow_location variable and opts hash in the template).
In `@config/clients/ruby/template/configuration_faraday_partial.mustache`:
- Around line 10-15: Update the outdated Ruby stdlib documentation link in the
TLS/SSL comment near the attr_accessor :ssl_verify_mode so it points to a
current or version-agnostic doc URL (e.g., docs.ruby-lang.org or a 3.x
OpenSSL/SSL page) instead of the EOL ruby-doc.org/stdlib-2.5.1 path; edit the
comment block above ssl_verify_mode in configuration_faraday_partial.mustache to
replace the old link with the chosen up-to-date URL.
In `@config/clients/ruby/template/configuration_httpx_partial.mustache`:
- Line 2: Update the outdated Ruby docs link in
configuration_httpx_partial.mustache (the comment starting with "You can use
this to customize SSL Context settings") to point to a current, version-agnostic
Ruby docs URL such as https://docs.ruby-lang.org/en/ or the latest
OpenSSL::SSL::SSLContext page on docs.ruby-lang.org instead of the old
ruby-doc.org/stdlib-2.5.1 path so the comment references up-to-date
documentation.
In `@config/clients/ruby/template/gemspec.mustache`:
- Around line 39-40: Remove the deprecated assignment to s.test_files in the
gemspec template: delete the line that sets s.test_files (the `s.test_files =
`find spec/*`.split("\n")` entry) from
config/clients/ruby/template/gemspec.mustache so the generated gemspec no longer
includes the obsolete attribute; leave the s.files line unchanged.
In `@config/clients/ruby/template/partial_oneof_module_doc.mustache`:
- Around line 44-46: The heading in the partial docs is incorrect: change the
Markdown heading text from `openapi_discriminator_name` to
`openapi_discriminator_mapping` so it matches the documented method
`.openapi_discriminator_mapping` and the description "Returns the
discriminator's mapping"; update the single-line heading at the top of that
section (the line currently showing ### `openapi_discriminator_name`) to ###
`openapi_discriminator_mapping`.
In `@config/clients/ruby/template/README_calling_api.mustache`:
- Line 362: Replace the two hardcoded API doc URLs
"https://openfga.dev/api/service" in the README_calling_api.mustache template
(the links that render as "[API
Documentation](https://openfga.dev/api/service#/Relationship%20Queries/BatchCheck)"
and the other occurrence) with the mustache variable {{apiDocsUrl}} so the links
become dynamic; locate the literal string "https://openfga.dev/api/service" in
the file and swap it for {{apiDocsUrl}} while keeping the fragment/path (e.g.,
`#/Relationship`%20Queries/BatchCheck) intact.
In `@config/clients/ruby/template/README_installation.mustache`:
- Around line 1-23: Replace the hardcoded gem name "openfga" in
README_installation.mustache with the mustache variable {{{gemName}}};
specifically update the three occurrences (the `gem install ...` line, the `gem
'...'` entry in the Gemfile example, and the `require '...'` line) to use
{{{gemName}}} so the generated README stays in sync with the generator
configuration.
🧹 Nitpick comments (8)
Makefile (1)
269-277: Ruby targets not wired intobuild-all-clients/test-all-clients.
build-client-rubyandtest-client-rubyare not included in the aggregate targets on lines 55 and 58. If this is intentional for the initial phase, consider adding a comment to explain why, so future contributors don't assume it was an oversight.Also, the
test-client-rubytarget body is empty (comment-only), which meansmake test-client-rubywill silently succeed without running any tests. This is fine for bootstrapping, but a$(warning ...)or@echonoting that tests are not yet implemented would make CI output less misleading.Suggested improvement
.PHONY: test-client-ruby test-client-ruby: build-client-ruby - # ... any custom test code ... + `@echo` "WARNING: Ruby SDK tests are not yet implemented"config/clients/ruby/template/gem.mustache (1)
55-59: Generic upstream comment referencesusername/password— not applicable to OpenFGA.The
configureblock example referencesconfig.usernameandconfig.password, which are default OpenAPI generator boilerplate. For the OpenFGA SDK, this comment would be more useful if it showed OpenFGA-specific configuration (e.g.,api_url,store_id, orcredentials).config/clients/ruby/template/model_test.mustache (1)
32-32: HardcodedPetstorereference in commented example.The commented-out enum validator example references
Petstore::EnumTest::EnumAttributeValidatorinstead of using{{moduleName}}. While it's in a comment, generated test files will carry this stale reference, which may confuse SDK consumers.Suggested fix
- # validator = Petstore::EnumTest::EnumAttributeValidator.new('{{{dataType}}}', [{{`#allowableValues`}}{{`#enumVars`}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}]) + # validator = {{moduleName}}::EnumAttributeValidator.new('{{{dataType}}}', [{{`#allowableValues`}}{{`#enumVars`}}{{{value}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}])config/clients/ruby/template/api_error.mustache (1)
23-25: Arbitrary instance variable injection from hash keys.
instance_variable_set "@#{k}", vsets ivars for every key in the hash without validation. While this is an established upstream OpenAPI generator pattern, be aware it allows setting unexpected internal state if callers pass extra keys.config/clients/ruby/template/partial_anyof_module.mustache (1)
40-91: Near-identicalfind_and_cast_into_typelogic duplicated withpartial_oneof_module.mustache.The
find_and_cast_into_typeprivate helper (Lines 45–91) and theSchemaMismatchErrordefinition (Line 42) are virtually identical to the corresponding code inpartial_oneof_module.mustache. The only difference is that the oneOf variant checksopenapi_one_ofat Line 118 vs.openapi_any_ofhere at Line 76.Consider extracting the shared type-casting logic into a common partial or helper module to avoid divergence over time.
config/clients/ruby/template/api_model_base.mustache (1)
12-49:_deserializesilently coercesnilfor primitive types.When
valueisnil, the primitive branches silently produce lossy defaults:nil.to_i → 0,nil.to_f → 0.0,nil.to_s → "", and the Boolean regex maps it tofalse. TheTime/Date/Array/Hashbranches will raise.This is a known pattern in upstream OpenAPI generators (callers are expected to nil-guard), but worth flagging given that the anyOf/oneOf
buildpaths could feed arbitrary data through here.config/clients/ruby/template/api_client_faraday_partial.mustache (1)
157-159: Potential nil dereference ifopts[:header_params]is missing.
connection(opts)accessesopts[:header_params]['Content-Type']without a nil guard. Ifconnectionis ever called with opts that don't include:header_params, this will raise aNoMethodError. Currently safe becausecall_apialways passes the full opts hash from the generated API methods, but this is fragile.🛡️ Suggested defensive fix
def connection(opts) - opts[:header_params]['Content-Type'] == 'multipart/form-data' ? connection_multipart : connection_regular + opts.dig(:header_params, 'Content-Type') == 'multipart/form-data' ? connection_multipart : connection_regular endconfig/clients/ruby/template/configuration.mustache (1)
368-388:gsub!mutates the URL string fromserver_settingsin-place.Lines 377 and 383 use
url.gsub!which mutates the string obtained viaurl = server[:url]. This is safe today becauseserver_settingsandoperation_server_settingsreturn fresh data structures on every call, but it would silently break if either method were memoized in the future. Using non-mutatinggsub(or.dupon line 369) would be more defensive.♻️ Suggested defensive fix
server = servers[index] - url = server[:url] + url = server[:url].dup
config/clients/ruby/template/configuration_httpx_partial.mustache
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This PR adds the Ruby client generation scaffolding to the OpenFGA SDK Generator, including Ruby-specific OpenAPI Generator templates, configuration overrides, and Makefile targets to build/test the Ruby SDK output.
Changes:
- Introduces a full set of Ruby OpenAPI Generator templates (models, APIs, client/config, docs).
- Adds Ruby client configuration overrides and generator metadata for the build system.
- Adds Makefile targets to build/test the Ruby client.
Reviewed changes
Copilot reviewed 39 out of 42 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
Makefile |
Adds build-client-ruby / test-client-ruby targets. |
config/clients/ruby/.openapi-generator-ignore |
Adds Ruby-specific ignore patterns for generated output. |
config/clients/ruby/config.overrides.json |
Defines Ruby SDK metadata (gem/package/module naming, versions, library choice, custom supporting files). |
config/clients/ruby/template-source.json |
Declares the upstream generator/template source reference for Ruby. |
config/clients/ruby/template/api.mustache |
Ruby API class template for operations. |
config/clients/ruby/template/api_client.mustache |
Ruby API client entry template and shared helpers (deserialize/auth/header selection). |
config/clients/ruby/template/api_client_faraday_partial.mustache |
Faraday transport implementation for API calls and file handling. |
config/clients/ruby/template/api_client_httpx_partial.mustache |
HTTPX transport implementation for API calls and file handling. |
config/clients/ruby/template/api_client_typhoeus_partial.mustache |
Typhoeus transport implementation for API calls and file handling. |
config/clients/ruby/template/api_doc.mustache |
Markdown API docs template. |
config/clients/ruby/template/api_error.mustache |
Ruby exception type template for API errors. |
config/clients/ruby/template/api_info.mustache |
Shared API info banner included into generated files. |
config/clients/ruby/template/api_model_base.mustache |
Base model helpers (deserialize/to_hash helpers) for generated models. |
config/clients/ruby/template/api_test.mustache |
RSpec API test template (generated scaffolding). |
config/clients/ruby/template/base_object.mustache |
Shared model build/to_hash logic inserted into model classes. |
config/clients/ruby/template/configuration.mustache |
SDK configuration object template (auth, servers, transport-specific settings). |
config/clients/ruby/template/configuration_faraday_partial.mustache |
Faraday-specific configuration attributes. |
config/clients/ruby/template/configuration_httpx_partial.mustache |
HTTPX-specific configuration attributes. |
config/clients/ruby/template/configuration_typhoeus_partial.mustache |
Typhoeus-specific configuration attributes. |
config/clients/ruby/template/constants.mustache |
OpenFGA Ruby SDK constants (SDK_VERSION, USER_AGENT, defaults, retry/timeouts). |
config/clients/ruby/template/gem.mustache |
Gem entrypoint requiring generated components and providing .configure. |
config/clients/ruby/template/gemspec.mustache |
Gem specification template (deps, metadata, required Ruby version). |
config/clients/ruby/template/gitignore_custom.mustache |
Custom gitignore hook (currently empty). |
config/clients/ruby/template/model.mustache |
Ruby model file template wiring enums/oneOf/anyOf/generic models. |
config/clients/ruby/template/model_doc.mustache |
Model documentation dispatch template (oneOf vs generic). |
config/clients/ruby/template/model_test.mustache |
RSpec model test template (generated scaffolding). |
config/clients/ruby/template/partial_anyof_module.mustache |
anyOf helper module template (type matching/casting). |
config/clients/ruby/template/partial_header.mustache |
Header banner template for generated Ruby files. |
config/clients/ruby/template/partial_model_enum_class.mustache |
Enum class template. |
config/clients/ruby/template/partial_model_generic.mustache |
Generic model class template (attrs, validation, serialization hooks). |
config/clients/ruby/template/partial_model_generic_doc.mustache |
Generic model markdown doc template. |
config/clients/ruby/template/partial_oneof_module.mustache |
oneOf helper module template (discriminator + type matching/casting). |
config/clients/ruby/template/partial_oneof_module_doc.mustache |
oneOf module markdown doc template. |
config/clients/ruby/template/README_api_endpoints.mustache |
README section template listing endpoints. |
config/clients/ruby/template/README_calling_api.mustache |
README content template with Ruby examples for calling APIs. |
config/clients/ruby/template/README_custom_badges.mustache |
README badges hook (currently empty). |
config/clients/ruby/template/README_initializing.mustache |
README content template for SDK initialization patterns. |
config/clients/ruby/template/README_installation.mustache |
README content template for gem installation. |
config/clients/ruby/template/README_license_disclaimer.mustache |
README license disclaimer hook (currently empty). |
config/clients/ruby/template/README_models.mustache |
README section template listing models. |
config/clients/ruby/template/Rakefile.mustache |
Rake tasks template for running specs. |
config/clients/ruby/template/version.mustache |
Version file template exposing {{moduleName}}::VERSION. |
Description
What problem is being solved?
This is the required Ruby SDK client generation setup, including:
Everything else to be produced and managed inside the SDK repo itself: https://github.com/carlastabile/openfga-ruby-sdk
References
Review Checklist
mainSummary by CodeRabbit
Release Notes